//
//  LCMainTabBarController.m
//  HQBProject
//
//  Created by taolei-mac on 2017/4/18.
//  Copyright © 2017年 com.zhejiangchain.ios. All rights reserved.
//

#import "LCMainTabBarController.h"
#import "LCProfileViewController.h"
#import "LCLoanViewController.h"
#import "LCNavigationController.h"

@interface LCMainTabBarController ()

@end

@implementation LCMainTabBarController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self setupItemTitleTextAttributes];
    
    [self addAllChildVCs];
   
}

- (void)setupItemTitleTextAttributes
{
    UITabBarItem *item = [UITabBarItem appearance];
    // 未选中状态下的文字属性
    NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary];
    normalAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:15];
    normalAttrs[NSForegroundColorAttributeName] = [UIColor lightGrayColor];
    [item setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];
    
    // 选中状态下的文字属性
    NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
    selectedAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:15];
    selectedAttrs[NSForegroundColorAttributeName] = [UIColor grayColor];
    [item setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];
    
}

/**
  * 添加一个子控制器
 @param childVC 添加的子控制器
 @param title  标题
 @param imageName 图标
 @param selectedImageName 选中图标
 */
- (void)addOneChildVC:(UIViewController *)childVC title:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName
{
    childVC.tabBarItem.title = title;
    
    if(imageName.length){
        childVC.tabBarItem.image = [UIImage imageNamed:imageName];
        childVC.tabBarItem.selectedImage = [UIImage imageNamed:selectedImageName];
    }
    
    [self addChildViewController:childVC];
}

/**
 *   添加所有子控制器
 */
- (void)addAllChildVCs
{
    [self addOneChildVC:[[LCNavigationController alloc] initWithRootViewController:[[LCLoanViewController alloc] init]] title:@"借款" imageName:@"" selectedImageName:@""];
    
    [self addOneChildVC:[[LCNavigationController alloc] initWithRootViewController:[[LCProfileViewController alloc] init]] title:@"我的" imageName:@"" selectedImageName:@""];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    
}



@end
